package com.example.myapplication;

import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.util.List;
import java.util.Map;
import java.util.Objects;

public class Myadapter3 extends RecyclerView.Adapter<Myadapter3.Myholder>{
    Context context3;
    List<Map<String,Object>> list3;
    public Myadapter3(Context context, List<Map<String,Object>> list){
        this.context3 = context;
        this.list3 = list;
    }


    @NonNull
    @Override
    public Myholder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context3).inflate(R.layout.item3,parent,false);
        Myholder holder=new Myholder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(@NonNull Myholder holder, int position) {
        Map<String,Object> itemMap = list3.get(position);
        int picture= Objects.requireNonNull(itemMap.get("picture")).hashCode();
        String text3= Objects.requireNonNull(itemMap.get("text").toString());
        holder.textView.setText(text3);
        holder.imageView.setImageResource(picture);

    }

    @Override
    public int getItemCount() {

        return list3.size();
    }




    public class Myholder extends RecyclerView.ViewHolder {
        ImageView imageView;
        TextView textView;
        public Myholder(@NonNull View itemView) {
            super(itemView);
            imageView = itemView.findViewById(R.id.item_imageView7);
            textView = itemView.findViewById(R.id.item_textView7);
        }
    }

}
